{% extends 'admin/base.html' %}

{% block title %}
    提交内容
{% endblock %}

{% block css %}
    {{ super() }}
    <link href="{{ url_for('static',filename='plugins/select2/css/select2.min.css') }}" rel="stylesheet">
    <link href="{{ url_for('static',filename='plugins/bootstrap-select/bootstrap-select.min.css') }}" rel="stylesheet">
    <link href="{{ url_for('static',filename='plugins/chosen/chosen.min.css') }}" rel="stylesheet">
    <link rel="stylesheet" type="text/css"
          href="{{ url_for('static', filename='simditor-2.3.23/assets/styles/simditor.css') }}"/>
{% endblock %}

{% block script %}
    {{ super() }}
    <script type="text/javascript"
            src="{{ url_for('static', filename='plugins/bootstrap-select/bootstrap-select.min.js') }}"></script>
    <script type="text/javascript" src="{{ url_for('static', filename='plugins/select2/js/select2.min.js') }}"></script>
    <script type="text/javascript"
            src="{{ url_for('static', filename='simditor-2.3.23/assets/scripts/module.js') }}"></script>
    <script type="text/javascript"
            src="{{ url_for('static', filename='simditor-2.3.23/assets/scripts/uploader.js') }}"></script>
    <script type="text/javascript"
            src="{{ url_for('static', filename='simditor-2.3.23/assets/scripts/hotkeys.js') }}"></script>
    <script type="text/javascript"
            src="{{ url_for('static', filename='simditor-2.3.23/assets/scripts/dompurify.js') }}"></script>
    <script type="text/javascript"
            src="{{ url_for('static', filename='simditor-2.3.23/assets/scripts/simditor.js') }}"></script>
    <script>
        $(document).ready(function () {
            var $preview, editor, mobileToolbar, toolbar;
            toolbar = ['title', 'bold', 'italic', 'underline', 'strikethrough', 'fontScale', 'color', '|', 'ol', 'ul', 'blockquote', 'code', 'table', '|', 'link', 'image', 'hr', '|', 'indent', 'outdent', 'alignment'];
            mobileToolbar = ["bold", "underline", "strikethrough", "color", "ul", "ol"];
            editor = new Simditor({
                textarea: $('#editor'),
                placeholder: '这里输入文字...',
                toolbar: toolbar,
                pasteImage: false,
                defaultImage: "{{ url_for('static', filename='simditor-2.3.23/assets/images/image.png') }}",
                upload: {
                    url: '/upload/', //文件上传的接口地址
                    params: null, //键值对,指定文件上传接口的额外参数,上传的时候随文件一起提交
                    fileKey: 'file', //服务器端获取文件数据的参数名
                    connectionCount: 3,
                    leaveConfirm: '正在上传文件'
                }
            });
        });
    </script>
{% endblock %}

{% block admin_content %}
    <div class="row">
        <div class="col-md-2"></div>
        <div class="col-md-8">
            <div class="panel">
                <div class="panel-heading">
                    <h3 class="panel-title">发表博文</h3>
                </div>
                <div class="panel-body">
                    <div class="entry-box submit-article">
                        <form class="submit-article" method="post" action="">
                            {{ form.csrf_token }}
                            <div class="form-group">
                                {{ form.title.label(class='control-label') }} （1-50字）<br>
                                {{ form.title(class='submit-article-title form-control', required='') }}
                            </div>
                            <div class="form-group">
                                {{ form.source_user.label(class='control-label') }} （1-10字）<br>
                                {{ form.source_user(class='submit-article-title form-control', required='') }}
                            </div>
                            <div class="form-group">
                                {{ form.source_url.label(class='control-label') }}（显示在博客详情页）<br>
                                {{ form.source_url(class='form-control') }}
                            </div>
                            <div class="form-group">
                                {{ form.types.label(class='control-label') }}：
                                {{ form.types(class='form-control') }}
                            </div>
                            <div class="form-group">
                                {{ form.summary.label(class='control-label') }}（显示在博客首页）<br>
                                {{ form.summary(class='submit-article-summary form-control') }}
                            </div>
                            <div class="form-group">
                                {{ form.tags.label(class='control-label') }}（<br>
                                {{ form.tags(class='form-control') }}
                            </div>
                            <div class="form-group">
                                {{ form.content(id="editor") }}
                            </div>
                            <div class="submit-article-button">
                                <button type="submit" class="btn btn-success">提交</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

{% endblock %}